package cn.xjt.controller;

import cn.xjt.User.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 内容：
 *
 * @author
 * @date 2020/9/21-20:13
 */
@Controller
@RequestMapping("/user")
public class UserController {

	@RequestMapping("t1")
	public String test(@RequestParam("username") String name, Model model)
	{
		//接收前端参数
		System.out.println("接受前端的参数为："+name);
		//将得到的数据返回个客户端
		model.addAttribute("msg", name);
		//跳转视图
		return "hello";
	}

	//前端接收的是一个对象
	@RequestMapping("/t2")
	public String test2(User user)
	{
		System.out.println(user);
		return "hello";
	}
}
